package com.novellotus.iov.carvice.fragment;

import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.amap.api.services.core.AMapException;
import com.amap.api.services.core.LatLonPoint;
import com.amap.api.services.geocoder.GeocodeResult;
import com.amap.api.services.geocoder.GeocodeSearch;
import com.amap.api.services.geocoder.RegeocodeQuery;
import com.amap.api.services.geocoder.RegeocodeResult;
import com.novellotus.httploadingview.LoadingView;
import com.novellotus.iov.carvice.R;
import com.novellotus.iov.carvice.adapter.CarAlarmAdapter;
import com.novellotus.iov.carvice.bean.MqttVehicleBean;
import com.novellotus.iov.carvice.bean.RxCarData;
import com.novellotus.iov.carvice.model.CarStatuesFragmentModel;
import com.novellotus.iov.carvice.retrofit.BaseEntity;
import com.novellotus.iov.carvice.retrofit.BaseObserver;
import com.novellotus.iov.carvice.retrofit.RetrofitFactory;
import com.novellotus.iov.carvice.retrofit.RxSchedulers;
import com.novellotus.iov.carvice.utils.MyUtils;
import com.novellotus.iov.carvice.utils.MyViewUtils;
import com.novellotus.iov.carvice.utils.SharedPreferencesUtils;
import com.novellotus.iov.carvice.view.MnScaleBar;

import java.util.List;

import butterknife.BindView;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.functions.Consumer;

/**
 * 车辆刷新布局，通过mqtt数据刷新车辆状态
 */
public class CarStatuesFragment extends BaseCarFragment implements LoadingView.OnBtnClickListener, GeocodeSearch.OnGeocodeSearchListener, CarStatuesFragmentModel.CarStatuesFragmentModelInterface {

    @BindView(R.id.mnScaleBar)
    MnScaleBar mnScaleBar;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    @BindView(R.id.tv_model)
    TextView tv_model;
    @BindView(R.id.tv_vin)
    TextView tv_vin;
    @BindView(R.id.tv_location)
    TextView tv_location;
    @BindView(R.id.tv_time)
    TextView tv_time;
    //车辆状态
    @BindView(R.id.tv_statue_value)
    TextView tv_statue_value;
    //电池电量
    @BindView(R.id.tv_soc_value)
    TextView tv_soc_value;
    //总里程
    @BindView(R.id.tv_total_value)
    TextView tv_total_value;
    //充电状态
    @BindView(R.id.tv_charge_statue)
    TextView tv_charge_statue;
    //车速
    @BindView(R.id.tv_speed_value)
    TextView tv_speed_value;
    //电压
    @BindView(R.id.tv_voltage_value)
    TextView tv_voltage_value;
    //发动机转速
    @BindView(R.id.tv_motor_value)
    TextView tv_motor_value;
    //电流
    @BindView(R.id.tv_current_value)
    TextView tv_current_value;
    @BindView(R.id.imgCar)
    ImageView imgCar;
    @BindView(R.id.img_soc_background)
    ImageView img_soc_background;
    @BindView(R.id.img_soc_tips)
    ImageView img_soc_tips;
    @BindView(R.id.tv_soc)
    TextView tv_soc;
    @BindView(R.id.tv_finish_value)
    TextView tv_finish_value;
    @BindView(R.id.img_logo)
    ImageView img_logo;
    //报警
    @BindView(R.id.img_alarm_top)
    ImageView img_alarm_top;
    @BindView(R.id.img_alarm_bottom)
    ImageView img_alarm_bottom;
    @BindView(R.id.icon_alarm_tips)
    ImageView icon_alarm_tips;
    @BindView(R.id.tv_level)
    TextView tv_level;
    @BindView(R.id.tv_level_english)
    TextView tv_level_english;
    @BindView(R.id.tv_alarm_count)
    TextView tv_alarm_count;
    @BindView(R.id.rlt_progress)
    RelativeLayout rlt_progress;//进度条布局
    @BindView(R.id.tv_least)
    TextView tv_least;
    @BindView(R.id.tv_least_english)
    TextView tv_least_english;
    @BindView(R.id.rlt_alarm)
    RelativeLayout rlt_alarm;//报警布局
    @BindView(R.id.tv_begin)
    TextView tv_begin;
    @BindView(R.id.tv_middle)
    TextView tv_middle;
    @BindView(R.id.tv_end)
    TextView tv_end;
    @BindView(R.id.icon_run)
    ImageView icon_run;
    @BindView(R.id.icon_electricity)
    ImageView icon_electricity;
    @BindView(R.id.loadingView)
    LoadingView loadingView;
    @BindView(R.id.rlt_car)
    RelativeLayout rlt_car;

    String plate = "";
    String vin = "";
    String logo = "";
    String model = "";
    // RxCarData rxCarData;
    private GeocodeSearch geocoderSearch;
    private CarStatuesFragmentModel carStatuesFragmentModel;

    public CarFragmentInterface carFragmentInterface;
    private CarAlarmAdapter carAlarmRecyclerAdapter;

    public CarStatuesFragment() {
        // Required empty public constructor
    }

    /**
     * @param plate Parameter 1.
     * @param vin   Parameter 2.
     */
    // TODO: Rename and change types and number of parameters
    public static CarStatuesFragment newInstance(String plate, String vin) {
        CarStatuesFragment fragment = new CarStatuesFragment();
        Bundle args = new Bundle();
        args.putString("plate", plate);
        args.putString("vin", vin);
        fragment.setArguments(args);
        return fragment;
    }


    @Override
    View initRootView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        Bundle bundle = getArguments();
        plate = bundle.getString("plate");
        vin = bundle.getString("vin");
        return inflater.inflate(R.layout.fragment_car_statues, container, false);
    }

    @Override
    void init() {
        //   imgCar.setBackgroundResource(R.mipmap.icon_car_charging);
        tv_vin.setText(vin);
        carStatuesFragmentModel = new CarStatuesFragmentModel(this, this);
        getData();
        recyclerView.setLayoutManager(MyViewUtils.gridLayoutManager(getContext(), 2));
        initLocation();
        loadingView.setLoadingModel(LoadingView.MODEL_ALERT);
        loadingView.setOnBtnClickListener(this);
    }


    /**
     * 初始化定位
     */
    private void initLocation() {
        geocoderSearch = new GeocodeSearch(getContext());
        geocoderSearch.setOnGeocodeSearchListener(this);
    }

    /**
     * 定位
     */
    private void getLocation(final double lat, final double lng) {
        Observable.create(new ObservableOnSubscribe<CharSequence>() {
            @Override
            public void subscribe(ObservableEmitter<CharSequence> e) throws Exception {
                e.onNext("go");
            }
        }).compose(RxSchedulers.<CharSequence>composeIo()).subscribe(new Consumer<CharSequence>() {
            @Override
            public void accept(CharSequence o) throws Exception {
                LatLonPoint latLonPoint = new LatLonPoint(lat, lng);
                RegeocodeQuery query = new RegeocodeQuery(latLonPoint, 200, GeocodeSearch.GPS);// 第一个参数表示一个Latlng，第二参数表示范围多少米，第三个参数表示是火系坐标系还是GPS原生坐标系
                MyUtils.logInformation("开始搜索地址" + getPlate());
                geocoderSearch.getFromLocationAsyn(query);// 设置异步逆地理编码请求
            }
        });
    }

    /**
     * 获取单车数据
     */
    public void getData() {
        Observable<BaseEntity<RxCarData>> observable = RetrofitFactory.getInstance().getVehicleData(vin, SharedPreferencesUtils.getKey(getContext())[0]);
        observable.compose(RxSchedulers.<BaseEntity<RxCarData>>compose())
                .subscribe(new BaseObserver<RxCarData>(getContext()) {
                    @Override
                    public void onSuccess(RxCarData response) {
                        loadingView.success();
                        setData(response);
                        rlt_car.setVisibility(View.VISIBLE);
                        if (carFragmentInterface != null) {
                            carFragmentInterface.loadStatue(1);
                        }

                    }

                    @Override
                    public void onFail(int code, String msg) {
                        loadingView.empty(msg, true);
                        rlt_car.setVisibility(View.INVISIBLE);
                        if (carFragmentInterface != null) {
                            carFragmentInterface.loadStatue(0);
                        }
                    }

                    @Override
                    public void onError(String msg) {
                        loadingView.empty("网络请求失败", true);
                        rlt_car.setVisibility(View.INVISIBLE);
                        try {
                            if (carFragmentInterface != null) {
                                carFragmentInterface.loadStatue(0);
                            }
                        } catch (Exception e) {
                            MyUtils.logInformation(e.toString());
                        }

                    }
                });
    }


    @Override
    public String getPlate() {
        return MyUtils.getPlateString(plate);
    }

    @Override
    public String getVin() {
        return vin;
    }


    public String getAddress() {
        return tv_location.getText().toString();
    }

    @Override
    public String getModel() {
        return model;
    }

    @Override
    public int getType(RxCarData rxCarData) {
        return MyUtils.carDetailType(rxCarData.getMonitorStatus().getOnlineStatus(), rxCarData.getMonitorStatus().getChargeStatus(), rxCarData.getMonitorStatus().getAlarmStatus());
    }

    int carDetailType = 0;

    @Override
    public void setData(RxCarData rxCarData) {
        if (rxCarData != null && getContext() != null) {
            //车架
            tv_vin.setText(MyUtils.getRealValue(rxCarData.getVin()));

            //基础数据
            if (rxCarData.getMonitorStatus() != null) {
                //车型
                model = MyUtils.getRealValue(rxCarData.getMonitorStatus().getName());
                tv_model.setText(model);
                if (rxCarData.getMonitorStatus().getVehicleStatus() == 0) {
                    tv_statue_value.setText("- -");
                } else {
                    tv_statue_value.setText(rxCarData.getMonitorStatus().getVehicleStatus() == 1 ? "启动" : "熄火");
                }
                //充电状态
                if (rxCarData.getMonitorStatus().getChargeStatus() == 0) {
                    tv_charge_statue.setText("- -");
                } else {
                    tv_charge_statue.setText(rxCarData.getMonitorStatus().getChargeStatus() != 3 ? "on" : "off");
                }
                //车辆定位
                getLocation(rxCarData.getMonitorStatus().getLat(), rxCarData.getMonitorStatus().getLng());
                //logo
                logo = rxCarData.getMonitorStatus().getLogo();
                MyViewUtils.initImage(logo, img_logo, getActivity());
                int carType = MyUtils.carAlarmStatueBackground(rxCarData.getMonitorStatus().getOnlineStatus(), rxCarData.getMonitorStatus().getChargeStatus());
                carDetailType = MyUtils.carDetailType(rxCarData.getMonitorStatus().getOnlineStatus(), rxCarData.getMonitorStatus().getChargeStatus(), rxCarData.getMonitorStatus().getAlarmStatus());
                setCarStatue(carType, carDetailType);
            }
        //    mnScaleBar.setPercent(50, 2);
            //实时数据
            if (rxCarData.getReal_time_info() != null) {
                //采集时间
                tv_time.setText(MyUtils.getRealValue(rxCarData.getReal_time_info().getCollect_time()));
                //运行状态
                if (rxCarData.getReal_time_info().getVehicle() != null) {
                    //电量
                    setSoc(rxCarData.getReal_time_info().getVehicle().getSoc());
                    //总里程
                    tv_total_value.setText(MyUtils.getRealValue(rxCarData.getReal_time_info().getVehicle().getRecord_mileage() + ""));
                    //运行速度
                    tv_speed_value.setText(MyUtils.getRealValue(rxCarData.getReal_time_info().getVehicle().getSpeed() + ""));
                    //电压
                    tv_voltage_value.setText(MyUtils.getRealValue(rxCarData.getReal_time_info().getVehicle().getTotal_voltage() + ""));
                    //电流
                    tv_current_value.setText(MyUtils.getRealValue(rxCarData.getReal_time_info().getVehicle().getTotal_current() + ""));

                    switch (carDetailType) {
                        case 0:
                            mnScaleBar.setPercent(rxCarData.getReal_time_info().getVehicle().getSoc(), 1);
//                            mnScaleBar.setPercent(50, 1);
                            break;
                        case 1:
                            mnScaleBar.setPercent(rxCarData.getReal_time_info().getVehicle().getSpeed(), 2);
                            break;
                        case 2:
                            mnScaleBar.setPercent(rxCarData.getReal_time_info().getVehicle().getSoc(), 1);
                            break;
                        case 3:
                        case 4:
                        case 5:
                            setAdapter(rxCarData.getReal_time_info().getAlarm());
                            break;
                    }

                    if (rxCarData.getReal_time_info().getMotor() != null && rxCarData.getReal_time_info().getMotor().size() > 0) {
                        tv_motor_value.setText(rxCarData.getReal_time_info().getMotor().get(0).getSpeed() + "");
                    } else {
                        tv_motor_value.setText("- -");
                    }

                }
            }
        }


    }

    /**
     * 设置车辆状态
     */
    private void setCarStatue(int carStatue, int carDetailStatue) {

        //设置背景图
        switch (carStatue) {
            case 0:
                imgCar.setImageResource(R.mipmap.icon_car_outline);
//                imgCar.setImageResource(R.mipmap.icon_car_run);
                break;
            case 1:
                imgCar.setImageResource(R.mipmap.icon_car_run);
                break;
            case 2:
                imgCar.setImageResource(R.mipmap.icon_car_charging);
                break;
        }
        //根据不同状态处理不同事务
        switch (carDetailStatue) {
            case 0:
                rlt_alarm.setVisibility(View.INVISIBLE);
                rlt_progress.setVisibility(View.VISIBLE);
                img_alarm_top.setVisibility(View.GONE);
                img_alarm_bottom.setVisibility(View.GONE);
                icon_run.setVisibility(View.INVISIBLE);
                icon_electricity.setVisibility(View.VISIBLE);
                tv_finish_value.setText("");
                tv_finish_value.setVisibility(View.INVISIBLE);
                tv_least_english.setText("BATTERY");
                tv_least.setText("剩余电量");
                tv_begin.setText("0%");
                tv_middle.setText("50%");
                tv_end.setText("100%");
                break;
            case 1:
                icon_run.setVisibility(View.VISIBLE);
                icon_electricity.setVisibility(View.INVISIBLE);
                rlt_alarm.setVisibility(View.INVISIBLE);
                rlt_progress.setVisibility(View.VISIBLE);
                img_alarm_top.setVisibility(View.GONE);
                img_alarm_bottom.setVisibility(View.GONE);
                tv_least.setText("运行速度");
                tv_least_english.setText("SPEED");
                tv_finish_value.setText("km/h");
                tv_begin.setText("0");
                tv_middle.setText("90");
                tv_end.setText("180");
                break;
            case 2:
                icon_run.setVisibility(View.INVISIBLE);
                icon_electricity.setVisibility(View.VISIBLE);
                rlt_alarm.setVisibility(View.INVISIBLE);
                rlt_progress.setVisibility(View.VISIBLE);
                img_alarm_top.setVisibility(View.GONE);
                img_alarm_bottom.setVisibility(View.GONE);
                tv_finish_value.setVisibility(View.VISIBLE);
                tv_finish_value.setText("充电中");
                tv_least.setText("充电动态");
                tv_least_english.setText("CHARGING");
                tv_begin.setText("0%");
                tv_middle.setText("50%");
                tv_end.setText("100%");
                break;
            case 3:
                rlt_alarm.setVisibility(View.VISIBLE);
                rlt_progress.setVisibility(View.INVISIBLE);
                img_alarm_top.setVisibility(View.VISIBLE);
                img_alarm_bottom.setVisibility(View.VISIBLE);
                img_alarm_top.setBackgroundResource(R.mipmap.icon_alarm_level_one);
                img_alarm_bottom.setBackgroundResource(R.mipmap.icon_alarm_level_one);
                icon_alarm_tips.setImageResource(R.mipmap.icon_alarm_level_one_tips);
                tv_level.setTextColor(Color.parseColor("#f7be0e"));
                tv_level_english.setTextColor(Color.parseColor("#7b6147"));
                tv_alarm_count.setTextColor(Color.parseColor("#f7be0e"));
                tv_level.setText("一级报警");
                tv_level_english.setText("LEVEL 1");
                break;
            case 4:
                rlt_alarm.setVisibility(View.VISIBLE);
                rlt_progress.setVisibility(View.INVISIBLE);
                img_alarm_top.setVisibility(View.VISIBLE);
                img_alarm_bottom.setVisibility(View.VISIBLE);
                img_alarm_top.setBackgroundResource(R.mipmap.icon_alarm_level_two);
                img_alarm_bottom.setBackgroundResource(R.mipmap.icon_alarm_level_two);
                icon_alarm_tips.setImageResource(R.mipmap.icon_alarm_level_two_tips);
                tv_level.setTextColor(Color.parseColor("#f66038"));
                tv_level_english.setTextColor(Color.parseColor("#7f3a4f"));
                tv_alarm_count.setTextColor(Color.parseColor("#f66038"));
                tv_level.setText("二级报警");
                tv_level_english.setText("LEVEL 2");
                break;
            case 5:
                rlt_alarm.setVisibility(View.VISIBLE);
                rlt_progress.setVisibility(View.INVISIBLE);
                img_alarm_top.setVisibility(View.VISIBLE);
                img_alarm_bottom.setVisibility(View.VISIBLE);
                img_alarm_top.setBackgroundResource(R.mipmap.icon_alarm_level_three);
                img_alarm_bottom.setBackgroundResource(R.mipmap.icon_alarm_level_three);
                icon_alarm_tips.setImageResource(R.mipmap.icon_alarm_level_three_tips);
                tv_level.setTextColor(Color.parseColor("#ed3760"));
                tv_level_english.setTextColor(Color.parseColor("#77295b"));
                tv_alarm_count.setTextColor(Color.parseColor("#ed3760"));
                tv_level.setText("三级报警");
                tv_level_english.setText("LEVEL 3");
                break;
        }
    }

    /**
     * @param soc 设置电量状态
     */
    private void setSoc(int soc) {
        if (soc <= 10) {
            img_soc_background.setVisibility(View.VISIBLE);
            img_soc_tips.setVisibility(View.VISIBLE);
            tv_soc_value.setTextColor(Color.parseColor("#ea4269"));
            tv_soc.setTextColor(Color.parseColor("#903a6b"));


        } else {
            img_soc_background.setVisibility(View.GONE);
            img_soc_tips.setVisibility(View.GONE);
            tv_soc.setTextColor(Color.parseColor("#ffffff"));
            tv_soc_value.setTextColor(Color.parseColor("#ffffff"));
        }

        if (carDetailType == 2) {
            if (soc < 100) {

                tv_finish_value.setText("充电中");
            } else {
                tv_finish_value.setText("充电完成");
            }
        }

        tv_soc_value.setText(soc + "%");
    }

    /**
     * @param alarmBean 设置报警列表
     */
    private void setAdapter(RxCarData.RealTimeInfoBean.AlarmBean alarmBean) {
        List<String> alarmList = carStatuesFragmentModel.getAlarmList(alarmBean);
        tv_alarm_count.setText("(" + alarmList.size() + ")");
        carAlarmRecyclerAdapter = new CarAlarmAdapter(alarmBean.getHighest_alarm_level(), alarmList);
        recyclerView.setAdapter(carAlarmRecyclerAdapter);
    }

    /**
     * @param alarmBean 通过mqtt更新报警列表
     */
    private void setAdapter(MqttVehicleBean.AlarmBean alarmBean) {
        List<String> alarmList = carStatuesFragmentModel.getAlarmList(alarmBean);
        tv_alarm_count.setText("(" + alarmList.size() + ")");
        carAlarmRecyclerAdapter = new CarAlarmAdapter(alarmBean.getHighest_alarm_level(), alarmList);
        recyclerView.setAdapter(carAlarmRecyclerAdapter);
    }

    @Override
    public void setInterface(CarFragmentInterface carFragmentInterface) {
        this.carFragmentInterface = carFragmentInterface;
    }


    /**
     * 通过车辆状态主题和整车主题分别获得车辆的状态和数据
     * 进行刷新
     */
    public void mqttUpdate(MqttVehicleBean mqttVehicleBean, int carType, int detailType) {
        if (mqttVehicleBean != null) {
            tv_time.setText(mqttVehicleBean.getCollect_time());
            if (mqttVehicleBean.getVehicle() != null) {

                //车辆状态
                tv_statue_value.setText(mqttVehicleBean.getVehicle().getVehicle_status() == 1 ? "启动" : "熄火");

                tv_charge_statue.setText(mqttVehicleBean.getVehicle().getCharge_status() != 3 ? "on" : "off");
                tv_total_value.setText(MyUtils.getRealValue(mqttVehicleBean.getVehicle().getRecord_mileage() + ""));
                //充电状态
                tv_speed_value.setText(MyUtils.getRealValue(mqttVehicleBean.getVehicle().getSpeed() + ""));
                tv_voltage_value.setText(MyUtils.getRealValue(mqttVehicleBean.getVehicle().getTotal_voltage() + ""));
                tv_current_value.setText(MyUtils.getRealValue(mqttVehicleBean.getVehicle().getTotal_current() + ""));

                //   int carType = MyUtils.carAlarmStatueBackground(mqttVehicleBean.getVehicle().getVehicle_status(), mqttVehicleBean.getVehicle().getCharge_status());
                //     int carDetailType = MyUtils.carDetailType(mqttVehicleBean.getVehicle().getVehicle_status(), mqttVehicleBean.getVehicle().getCharge_status(), mqttVehicleBean.getAlarm().getHighest_alarm_level());
                setCarStatue(carType, detailType);
                setSoc(mqttVehicleBean.getVehicle().getSoc());
                switch (detailType) {
                    case 0:
                        //离线状态
                        mnScaleBar.setPercent(mqttVehicleBean.getVehicle().getSoc(), 1);
                        break;
                    case 1:
                        //在线状态
                        mnScaleBar.setPercent(mqttVehicleBean.getVehicle().getSpeed(), 2);
                        if (mqttVehicleBean.getLocation() != null)
                            getLocation(mqttVehicleBean.getLocation().getLat(), mqttVehicleBean.getLocation().getLng());
                        break;
                    case 2:
                        //充电状态
                        mnScaleBar.setPercent(mqttVehicleBean.getVehicle().getSoc(), 1);
                        break;
                    case 3:
                    case 4:
                    case 5:
                        setAdapter(mqttVehicleBean.getAlarm());
                        break;
                }
                // setCarStatue(MyUtils.carAlarmStatueBackground(mqttVehicleBean.getVehicle().getVehicle_status(), mqttVehicleBean.getVehicle().getCharge_status()), MyUtils.carDetailType(mqttVehicleBean.getVehicle().getVehicle_status(), mqttVehicleBean.getVehicle().getCharge_status(), mqttVehicleBean.getAlarm().getHighest_alarm_level()));
            }

            if (mqttVehicleBean.getMotor() != null && mqttVehicleBean.getMotor().size() > 0) {
                tv_motor_value.setText(mqttVehicleBean.getMotor().get(0).getSpeed() + "");
            } else {
                tv_motor_value.setText("- -");
            }
            //如果是充电状态速度都设置为0
//            if (carType == 2) {
//                tv_speed_value.setText("0");
//                tv_motor_value.setText("0");
//            }

        }
    }


    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if (context instanceof CarFragmentInterface) {
            carFragmentInterface = (CarFragmentInterface) context;
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        carFragmentInterface = null;
    }

    @Override
    public void onRegeocodeSearched(RegeocodeResult result, int rCode) {
        if (rCode == AMapException.CODE_AMAP_SUCCESS) {
            if (result != null && result.getRegeocodeAddress() != null
                    && result.getRegeocodeAddress().getFormatAddress() != null) {
                String addressName = result.getRegeocodeAddress().getFormatAddress()
                        + "附近";
                tv_location.setText(addressName);
            } else {
                tv_location.setText("无法定位当前车辆位置");
            }
        } else {
            tv_location.setText("无法定位当前车辆位置");
        }
    }

    @Override
    public void onGeocodeSearched(GeocodeResult geocodeResult, int i) {

    }

    @Override
    public void onReload() {
        getData();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }
}
